package top.andnux.weather.controller;

import android.content.Context;

import top.andnux.weather.model.BaseModel;
import top.andnux.weather.view.BaseView;

public class BaseController<M extends BaseModel, V extends BaseView> {

    protected Context context;

    public BaseController(Context context) {
        this.context = context;
    }

    /**
     * 模型
     */
    protected M model;

    /**
     * 视图
     */
    protected V view;

    /**
     * 附着到视图上
     *
     * @param view
     */
    public void attachView(V view) {
        this.view = view;
    }

    /**
     * 是否关联视图
     *
     * @return
     */
    public boolean isAttachView() {
        return this.view != null;
    }

    /**
     * 取消关联视图
     */
    public void detachView() {
        if (view != null) {
            view.hideLoading();
            view = null;
        }
    }
}
